package training;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @Author liangzai
 * @Description:
 */
public class J25_6_3_Training {
    //玩具
    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long[] nums = new long[2*n+1];
        for (int i = 1; i <= 2*n; i++) {
            nums[i] = scanner.nextLong();
        }
        Arrays.sort(nums);
        long sum = 0;
        int left = 1;int right = 2*n;
        while(left<right){
            sum += nums[left++]*nums[right--];
        }
        System.out.println(sum);
    }

    //不完整的算式
    public static void main2(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String initString = scanner.next();
        int index = 1;
        StringBuffer[] stringBuffers = new StringBuffer[6];stringBuffers[1] = new StringBuffer();
        stringBuffers[2] = new StringBuffer();
        stringBuffers[3] = new StringBuffer();
        stringBuffers[4] = new StringBuffer();
        stringBuffers[5] = new StringBuffer();
        int pos = 0;
        for (int i = 0; i < initString.length(); i++) {
            char ch = initString.charAt(i);
            //System.out.print(ch);
            if(ch=='?'){
                if(i==0){
                    index--;
                }
                pos = index+1;
            }
            if(('0'>ch || '9'<ch)){
                stringBuffers[++index].append(ch);
            }else {
                if(i!=0) {
                    char val = initString.charAt(i - 1);
                    if (('0' > val || '9' < val)) {
                        index++;
                    }
                }
                stringBuffers[index].append(ch);
            }
        }
//        for (int i = 1; i < 6; i++) {
//            System.out.println(stringBuffers[i].toString());
//        }
        if(pos==1){
            if(stringBuffers[2].toString().equals("+")){
                int b = Integer.valueOf(stringBuffers[3].toString());
                int c = Integer.valueOf(stringBuffers[5].toString());
                System.out.println(c-b);
            }else if(stringBuffers[2].toString().equals("-")){
                int b = Integer.valueOf(stringBuffers[3].toString());
                int c = Integer.valueOf(stringBuffers[5].toString());
                System.out.println(c+b);
            }else if(stringBuffers[2].toString().equals("*")){
                int b = Integer.valueOf(stringBuffers[3].toString());
                int c = Integer.valueOf(stringBuffers[5].toString());
                System.out.println(c/b);
            }else {
                int b = Integer.valueOf(stringBuffers[3].toString());
                int c = Integer.valueOf(stringBuffers[5].toString());
                System.out.println(c*b);
            }
        }else if(pos == 2){
            //System.out.println(stringBuffers[3].toString());
            int a = Integer.valueOf(stringBuffers[1].toString());
            int b = Integer.valueOf(stringBuffers[3].toString());
            int c = Integer.valueOf(stringBuffers[5].toString());
            if(a-b==c){
                System.out.println("-");
            }else if(a+b==c){
                System.out.println("+");
            }else if(a*b==c){
                System.out.println("*");
            }else {
                System.out.println("/");
            }
        }else if(pos==3){
            int a = Integer.valueOf(stringBuffers[1].toString());
            int c = Integer.valueOf(stringBuffers[5].toString());
            String ch = stringBuffers[2].toString();
            if(ch.equals("+")){
                System.out.println(c-a);
            }else if(ch.equals("-")){
                System.out.println(a-c);
            }else if(ch.equals("*")){
                System.out.println(c/a);
            }else {
                System.out.println(a/c);
            }
        }else if(pos==5){
            int a = Integer.valueOf(stringBuffers[1].toString());
            int b = Integer.valueOf(stringBuffers[3].toString());
            String ch = stringBuffers[2].toString();
            if(ch.equals("+")){
                System.out.println(a+b);
            }else if(ch.equals("-")){
                System.out.println(a-b);
            }else if(ch.equals("*")){
                System.out.println(a*b);
            }else {
                System.out.println(a/b);
            }
        }
    }

    //序列1
    public static void main3(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long[] nums = new long[n+1];
        for (int i = 1; i <= n; i++) {
            nums[i] = scanner.nextLong();
        }
        long count = 0;
        for (int i = 1; i <= n; i++) {
            for (int j =1; j <= n; j++) {
                if(i*j%nums[j]==0){
                    count++;
                }
            }
        }
        System.out.println(count);
    }

    //序列
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long[] nums = new long[n+1];
        for (int i = 1; i <= n; i++) {
            nums[i] = scanner.nextLong();
        }
        long count = 0;
        for (int i = 1; i <= n; i++) {
            if(nums[i]==1 || nums[i] == i){
                count += n;
            }else{
                long min = Math.min(i,nums[i]);
                long max = Math.max(i,nums[i]);
                long ret = lcm(min,max);
                count += n*i/ret;
            }
        }
        System.out.println(count);
    }

    public static long lcm(long x,long y){
        return (x*y)/gcd(x,y);
    }


    public static long gcd(long x,long y){
        return y%x==0?x:gcd(y%x,x);
    }
}





